Xierqiu = cc.Node.extend({

	ctor:function(parent,tag){
		this._super();
		parent.addChild(this,9,TAG_XIERQIU_NODE);
		this.init(tag);
	},
	init:function(){
		var xieriqu = new Button(this, 10, TAG_XIERQIU, "#xierqiu.png",this.callback);	
	},
	yy:function(){
		var frames=[];
		for(var i=1;i<7;i++){
			var str ="yiye/y"+i+".png";
			var frame=cc.spriteFrameCache.getSpriteFrame(str);
			frames.push(frame);
		}

		var animation = new cc.Animation(frames,0.2);//负责动画序列
		var action = new cc.Animate(animation);//帧动画的动作创建
		return action;
	},
	callback:function(p){
		var action = gg.flow.flow.action;
		var func = cc.callFunc(this.actionDone, this);	
		switch(p.getTag()){
		case TAG_XIERQIU:
			if(action==ACTION_DO1){
				var yiyeguan = this.getParent().getChildByTag(TAG_YIYE);
				var move = cc.moveTo(1.5,cc.p(550,320));
				var movedown = cc.moveTo(0.5,cc.p(550,240));
				delay = cc.delayTime(0.5);
				delay1 = cc.delayTime(1);
				delay2 = cc.delayTime(3);
				var moveup =cc.moveTo(1,cc.p(550,320));
				var moveback=cc.moveTo(1,cc.p(700,200));
				var seq = cc.sequence(move,movedown,delay1,delay1,moveback);

				var move1 = cc.moveTo(1.5,cc.p(100,220));
				var movedown1 = cc.moveTo(0.5,cc.p(100,190));
				var moveup1 = cc.moveTo(1,cc.p(100,200));
				var moveback1 = cc.moveTo(1,cc.p(0,0));
				var seq1 =cc.sequence(move1,movedown1,func,delay1,moveup1,moveback1); 
				yiyeguan.runAction(seq);
				p.runAction(seq1);					
			}	
			if(action==ACTION_DO2){
				var sbeaker = this.getParent().getChildByTag(TAG_SBEAKER);
				var sbline = sbeaker.getChildByTag(TAG_SHOW);
				var yiyeguan = this.getParent().getChildByTag(TAG_YIYE);
				var move = cc.moveTo(1.5,cc.p(550,320));
				var movedown = cc.moveTo(0.5,cc.p(550,240));
				delay = cc.delayTime(1);
				delay1 = cc.delayTime(1.5);
				var moveup =cc.moveTo(1,cc.p(550,320));
				var moveback=cc.moveTo(1,cc.p(780,200));
				var cal = cc.callFunc(function(){
					var fadeto = cc.fadeOut(1.5);
					var spawn = cc.spawn(cc.moveBy(1.5,cc.p(0,-sbeaker.height * 0.2)));
					var seq = cc.sequence(spawn);
					sbline.runAction(seq);
				},this)					
				var seq = cc.sequence(move,movedown,cal,delay1,moveback);

				var move1 = cc.moveTo(1.5,cc.p(100,220));
				var movedown1 = cc.moveTo(0.5,cc.p(100,190));
				var moveup1 = cc.moveTo(1,cc.p(100,200));
				var moveback1 = cc.moveTo(1,cc.p(0,0));
				var seq1 =cc.sequence(move1,movedown1,func,delay,moveup1,moveback1); 
				yiyeguan.runAction(seq);
				p.runAction(seq1);				
			}
			if(action==ACTION_DO3){
				var hbottle = this.getParent().getChildByTag(TAG_HBOTTLE_NODE);
				var sbeaker = this.getParent().getChildByTag(TAG_SBEAKER);
				var yiyeguan = this.getParent().getChildByTag(TAG_YIYE);
				var move = cc.moveTo(1.5,cc.p(620,330));
				var movedown = cc.moveTo(0.5,cc.p(620,250));
				delay = cc.delayTime(3);
				delay1 = cc.delayTime(3);
				var moveup =cc.moveTo(1,cc.p(620,330));
				var moveback=cc.moveTo(1,cc.p(700,200));
				var cal = cc.callFunc(function(){
					var fadeto = cc.fadeOut(1.5);
					var spawn = cc.spawn(fadeto,cc.moveBy(1.5,cc.p(0,-sbeaker.height * 0.3)));
				},this)					
				var seq = cc.sequence(move,movedown,cal,delay1,moveup,moveback);


				var move1 = cc.moveTo(1.5,cc.p(170,230));
				var movedown1 = cc.moveTo(0.5,cc.p(170,200));
				var moveup1 = cc.moveTo(1,cc.p(170,250));
				var moveback1 = cc.moveTo(1,cc.p(0,0));
				var seq1 =cc.sequence(move1,movedown1,func,delay,moveup1,moveback1,cc.callFunc(function(){
					p.removeFromParent();
					hbottle.removeFromParent();
				})); 
				yiyeguan.runAction(seq);
				p.runAction(seq1);				
			}
			if(action==ACTION_DO4){
				var beaker1 = this.getParent().getChildByTag(TAG_BEAKER1);
				var bline1 = beaker1.getChildByTag(TAG_SHOW);
				var yiyeguan = this.getParent().getChildByTag(TAG_YIYE);
				var move = cc.moveTo(1.5,cc.p(550,320));
				var movedown = cc.moveTo(0.5,cc.p(550,240));
				delay = cc.delayTime(0.5);
				delay1 = cc.delayTime(1);
				var moveup =cc.moveTo(1,cc.p(550,320));
				var moveback=cc.moveTo(1,cc.p(700,200));
				var cal = cc.callFunc(function(){
					bline1.runAction(cc.moveBy(1,cc.p(0,-beaker1.height * 0.1)));
				},this)					
				var seq = cc.sequence(move,movedown,cal,delay1,moveback);
				var move1 = cc.moveTo(1.5,cc.p(100,220));
				var movedown1 = cc.moveTo(0.5,cc.p(100,190));
				var moveup1 = cc.moveTo(1,cc.p(100,200));
				var moveback1 = cc.moveTo(1,cc.p(0,0));
				var seq1 =cc.sequence(move1,movedown1,func,delay,moveup1,moveback1); 
				yiyeguan.runAction(seq);
				p.runAction(seq1);				
			}
			if(action==ACTION_DO5){
				var beaker1 = this.getParent().getChildByTag(TAG_BEAKER1);
				var bline1 = beaker1.getChildByTag(TAG_SHOW);
				var yiyeguan = this.getParent().getChildByTag(TAG_YIYE);
				var move = cc.moveTo(1.5,cc.p(550,320));
				var movedown = cc.moveTo(0.5,cc.p(550,240));
				delay = cc.delayTime(1);
				delay1 = cc.delayTime(1.5);
				var moveup =cc.moveTo(1,cc.p(550,320));
				var moveback=cc.moveTo(1,cc.p(700,200));
				var cal = cc.callFunc(function(){
					bline1.runAction(cc.moveBy(1,cc.p(0,-beaker1.height * 0.1)));
				},this)					
				var seq = cc.sequence(move,movedown,cal,delay1,moveback);

				var move1 = cc.moveTo(1.5,cc.p(100,220));
				var movedown1 = cc.moveTo(0.5,cc.p(100,190));
				var moveup1 = cc.moveTo(1,cc.p(100,200));
				var moveback1 = cc.moveTo(1,cc.p(0,0));
				var seq1 =cc.sequence(move1,movedown1,func,delay,moveup1,moveback1,cc.callFunc(function(){
					beaker1.removeFromParent();
				},this)); 
				yiyeguan.runAction(seq);
				p.runAction(seq1);				
			}
			break;
		
		}
		},
		actionDone:function(p){
			var action = gg.flow.flow.action;
			var func = cc.callFunc(this.actionDone, this);
			switch(p.getTag()){
			case TAG_XIERQIU:
				if(action==ACTION_DO1){
					var yiyeguan = this.getParent().getChildByTag(TAG_YIYE);
					var gesuan = this.getParent().getChildByTag(TAG_GESUAN);
					var yiye1 = new  cc.Sprite("#yyshou3_1.png");
					yiye1.setPosition(59,142);;		
					yiye1.setOpacity(0);
					yiyeguan.addChild(yiye1,5);
					var yiye2 = new  cc.Sprite("#yyshou3_2.png");
					yiye2.setPosition(59,142);
					yiye2.setOpacity(0);
					yiyeguan.addChild(yiye2,1);
					var fade = cc.fadeIn(1);
					var rotate = cc.rotateTo(1,90);
					var rotate1 = cc.rotateTo(1,0);
					var fadeout = cc.fadeOut(1);
					fadeout.retain();
					var delay = cc.delayTime(1.5);
					var seq1 = cc.sequence(fade,delay,fadeout);
					var seq2 = cc.sequence(rotate,delay,rotate1,cc.delayTime(1),cc.callFunc(function(){
						gesuan.removeFromParent();
					},this),cc.callFunc(this.getParent().flowNext,this));
					seq1.retain();
					seq2.retain();
					var cal = cc.callFunc(function(){
						yiye2.runAction(seq1);
						yiye1.runAction(fadeout);
						yiyeguan.runAction(seq2);

					},this); 
					var seq = cc.sequence(fade,delay,cal,delay,delay,fade,cc.callFunc(function(){
						yiyeguan.setSpriteFrame("yyshou3.png");
					},this),cc.callFunc(function(){
						yiye1.removeFromParent();
						yiye2.removeFromParent();
					},this));
					yiye1.runAction(seq);
				}


				if(action==ACTION_DO2){
//					var yiye = this.getParent().getChildByTag(TAG_YIYE);
//					yiye.setCascadeOpacityEnabled(true);
//					yiye.setSpriteFrame("yyshou.png");
//
//					var clyDtl = new cc.Sprite("#yiyeshow.png");
//					clyDtl.setPosition(yiye.width + clyDtl.width * 0.5,yiye.height * 0.5);
//					clyDtl.setOpacity(0);
//					clyDtl.setCascadeOpacityEnabled(true);
//					yiye.addChild(clyDtl);
//					var fade1 = cc.fadeTo(0.5, 255);
//					var delay = cc.delayTime(0.5);
//					var fade2 = cc.fadeTo(0.5,0);
//					var sequence = cc.sequence(fade1, delay, fade2,cc.callFunc(function(){
//						clyDtl.removeFromParent();
//					},this));
//					clyDtl.runAction(sequence);
//					var clyLine = new cc.Sprite("#cly_line.png");
//					clyDtl.addChild(clyLine);
//					clyLine.setPosition(clyDtl.width * 0.5, 0);
//					clyLine.runAction(cc.moveBy(1,cc.p(0,clyDtl.height * 0.4+5)));
//					var sequence  = cc.sequence(cc.delayTime(3),cc.callFunc(function(){
//						clyDtl.removeFromParent();
//					},this));
//					clyDtl.runAction(sequence);
//					var yiyeguan = this.getParent().getChildByTag(TAG_YIYE);
//					var gesuan = this.getParent().getChildByTag(TAG_GESUAN);
//					var yiye1 = new  cc.Sprite("#yyshou.png");
//					yiye1.setPosition(59,142);;		
//					yiye1.setOpacity(0);
//					yiyeguan.addChild(yiye1,5);
//					var yiye2 = new  cc.Sprite("#yyshou2_1.png");
//					yiye2.setPosition(59,142);
//					yiye2.setOpacity(0);
//					yiyeguan.addChild(yiye2,1);
//					var fade = cc.fadeIn(1);
//					var rotate = cc.rotateTo(1,90);
//					var rotate1 = cc.rotateTo(1,0);
//					var fadeout = cc.fadeOut(1);
//					fadeout.retain();
//					var delay = cc.delayTime(1.5);
//					var seq1 = cc.sequence(fade,delay,fadeout);
//					var seq2 = cc.sequence(rotate,delay,rotate1,cc.delayTime(1),cc.callFunc(this.getParent().flowNext,this));
//					seq1.retain();
//					seq2.retain();
//					var cal = cc.callFunc(function(){
//						yiye2.runAction(seq1);
//						yiye1.runAction(fadeout);
//						yiyeguan.runAction(seq2);
//
//					},this); 
//					var seq = cc.sequence(fade,delay,cal,delay,delay,fade,cc.callFunc(function(){
//						yiyeguan.setSpriteFrame("yyshou.png");
//					},this),cc.callFunc(function(){
//						yiye1.removeFromParent();
//						yiye2.removeFromParent();
//					},this));
//					yiye1.runAction(seq);
					var fadein = cc.fadeIn(0.5);
					var fadeout = cc.fadeOut(0.5);
					var yiyeguan = this.getParent().getChildByTag(TAG_YIYE);
					var clyLine = new cc.Sprite("#cly_line.png");
					yiyeguan.addChild(clyLine,1,TAG_SHOWLEFT);
					clyLine.setScale(0.3);
					clyLine.setPosition(yiyeguan.width * 0.5, 0);
					var spawn = cc.spawn(cc.scaleTo(0.3,0.6),cc.moveBy(0.3,cc.p(0,15)));
					var seq = cc.sequence(cc.moveBy(1,cc.p(0,yiyeguan.height * 0.4)),spawn,cc.delayTime(0.5),fadeout,cc.delayTime(3),fadein);
					clyLine.runAction(seq);				
					var shou = new cc.Sprite("#shou1.png");
					shou.setPosition(33,240);
					yiyeguan.addChild(shou,1,TAG_SHOW);
					var seq2 = cc.sequence(cc.delayTime(2.5),fadeout,cc.delayTime(3),fadein);
					shou.runAction(seq2);


					var rotate = cc.rotateTo(1,90);
					var rotate1 = cc.rotateTo(1,0);
					var delay = cc.delayTime(1.5);
					var seq1 = cc.sequence(cc.delayTime(2.5),rotate,cc.callFunc(function(){
						yiyeguan.runAction(this.yy());
					},this),delay,rotate1,cc.callFunc(this.getParent().flowNext,this));
					yiyeguan.runAction(seq1);
				
				}
				if(action==ACTION_DO3){
					var yiyeguan = this.getParent().getChildByTag(TAG_YIYE);
					var clyLine = new cc.Sprite("#cly_line.png");
					yiyeguan.addChild(clyLine,1,TAG_SHOWLEFT);
					clyLine.setScale(0.3);
					clyLine.setPosition(yiyeguan.width * 0.5, 0);
					var spawn = cc.spawn(cc.scaleTo(0.3,0.6),cc.moveBy(1,cc.p(0,65)));
					var spawn1 = cc.spawn(cc.scaleTo(0.3,0.3),cc.moveBy(1,cc.p(0,55)));
					var seq = cc.sequence(cc.moveBy(1,cc.p(0,yiyeguan.height * 0.4)),spawn,spawn1,cc.callFunc(this.getParent().flowNext,this));
					clyLine.runAction(seq);				
					var shou = new cc.Sprite("#shou1.png");
					shou.setPosition(33,240);
					yiyeguan.addChild(shou,1,TAG_SHOW);


//					var rotate = cc.rotateTo(1,90);
//					var rotate1 = cc.rotateTo(1,0);
//					var delay = cc.delayTime(1.5);
//					var seq1 = cc.sequence(cc.delayTime(2),rotate,cc.callFunc(function(){
//						yiyeguan.runAction(this.yy());
//					},this),delay,rotate1,cc.callFunc(this.getParent().flowNext,this));
				//	yiyeguan.runAction(seq1);
				}
				if(action==ACTION_DO4||action==ACTION_DO5){
//					var yiye = this.getChildByTag(TAG_YIYE);
//					yiye.setCascadeOpacityEnabled(true);
//					yiye.setSpriteFrame("yyshou.png");

//					var clyDtl = new cc.Sprite("#yiyeshow.png");
//					clyDtl.setPosition(yiye.width + clyDtl.width * 0.5,yiye.height * 0.5);
//					clyDtl.setOpacity(0);
//					clyDtl.setCascadeOpacityEnabled(true);
//					yiye.addChild(clyDtl);
//					var fade1 = cc.fadeTo(0.5, 255);
//					var delay = cc.delayTime(0.5);
//					var fade2 = cc.fadeTo(0.5,0);
//					var sequence = cc.sequence(fade1, delay, fade2,cc.callFunc(function(){
//					clyDtl.removeFromParent();
//					},this));
//					clyDtl.runAction(sequence);
//					var clyLine = new cc.Sprite("#cly_line.png");
//					clyDtl.addChild(clyLine);
//					clyLine.setPosition(clyDtl.width * 0.5, 0);
//					clyLine.runAction(cc.moveBy(1,cc.p(0,clyDtl.height * 0.4+5)));
//					var sequence  = cc.sequence(cc.delayTime(3),cc.callFunc(function(){
//					clyDtl.removeFromParent();
//					},this));
////					clyDtl.runAction(sequence);
					
					
//					var yiyeguan = this.getParent().getChildByTag(TAG_YIYE);
//					var gesuan = this.getParent().getChildByTag(TAG_GESUAN);
//					var yiye1 = new  cc.Sprite("#yyshou.png");
//					yiye1.setPosition(59,142);;		
//					yiye1.setOpacity(0);
//					yiyeguan.addChild(yiye1,5);
//					var yiye2 = new  cc.Sprite("#yyshou2_1.png");
//					yiye2.setPosition(59,142);
//					yiye2.setOpacity(0);
//					yiyeguan.addChild(yiye2,1);
//					var fade = cc.fadeIn(1);
//					var rotate = cc.rotateTo(1,90);
//					var rotate1 = cc.rotateTo(1,0);
//					var fadeout = cc.fadeOut(1);
//					fadeout.retain();
//					var delay = cc.delayTime(1.5);
//					var seq1 = cc.sequence(fade,delay,fadeout);
//					var seq2 = cc.sequence(rotate,delay,rotate1,cc.delayTime(1),cc.callFunc(this.getParent().flowNext,this));
//					seq1.retain();
//					seq2.retain();
//					var cal = cc.callFunc(function(){
//						yiye2.runAction(seq1);
//						yiye1.runAction(fadeout);
//						yiyeguan.runAction(seq2);
//
//					},this); 
//					var seq = cc.sequence(fade,delay,cal,delay,delay,fade,cc.callFunc(function(){
//						yiyeguan.setSpriteFrame("yyshou.png");
//					},this),cc.callFunc(function(){
//						yiye1.removeFromParent();
//						yiye2.removeFromParent();
//					},this));
//					yiye1.runAction(seq);
//				}
					var fadein = cc.fadeIn(0.5);
					var fadeout = cc.fadeOut(0.5);
					var yiyeguan = this.getParent().getChildByTag(TAG_YIYE);
					var clyLine = new cc.Sprite("#cly_line.png");
					yiyeguan.addChild(clyLine,1,TAG_SHOWLEFT);
					clyLine.setScale(0.3);
					clyLine.setPosition(yiyeguan.width * 0.5, 0);
					var spawn = cc.spawn(cc.scaleTo(0.3,0.6),cc.moveBy(0.3,cc.p(0,15)));
					var seq = cc.sequence(cc.moveBy(1,cc.p(0,yiyeguan.height * 0.4)),spawn,cc.delayTime(0.5),fadeout,cc.delayTime(3),fadein);
					clyLine.runAction(seq);				
					var shou = new cc.Sprite("#shou1.png");
					shou.setPosition(33,240);
					yiyeguan.addChild(shou,1,TAG_SHOW);
					var seq2 = cc.sequence(cc.delayTime(2.5),fadeout,cc.delayTime(3),fadein);
					shou.runAction(seq2);
					
					
					var rotate = cc.rotateTo(1,90);
					var rotate1 = cc.rotateTo(1,0);
					var delay = cc.delayTime(1.5);
					var seq1 = cc.sequence(cc.delayTime(2.5),rotate,cc.callFunc(function(){
						yiyeguan.runAction(this.yy());
					},this),delay,rotate1,cc.callFunc(this.getParent().flowNext,this));
					yiyeguan.runAction(seq1);
					
				}

				break;
			}
		}

})